
package com.daguchuangyi.erp_android.model.product;

import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.NonNull;

import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

import java.util.ArrayList;
import java.util.List;

public class Parameter implements Parcelable, Comparable<Parameter> {

    @SerializedName("optionValue")
    @Expose
    private List<String> optionValue = new ArrayList<String>();
    @SerializedName("id")
    @Expose
    private int id;
    @SerializedName("name")
    @Expose
    private String name;
    @SerializedName("type")
    @Expose
    private String type;
    @SerializedName("remark")
    @Expose
    private String remark;
    @SerializedName("createdAt")
    @Expose
    private String createdAt;
    @SerializedName("updatedAt")
    @Expose
    private String updatedAt;
    @SerializedName("productparameters")
    @Expose
    private Productparameters productparameters;
    public final static Creator<Parameter> CREATOR = new Creator<Parameter>() {


        @SuppressWarnings({
                "unchecked"
        })
        public Parameter createFromParcel(Parcel in) {
            return new Parameter(in);
        }

        public Parameter[] newArray(int size) {
            return (new Parameter[size]);
        }

    };

    protected Parameter(Parcel in) {
        in.readList(this.optionValue, (String.class.getClassLoader()));
        this.id = ((int) in.readValue((int.class.getClassLoader())));
        this.name = ((String) in.readValue((String.class.getClassLoader())));
        this.type = ((String) in.readValue((String.class.getClassLoader())));
        this.remark = ((String) in.readValue((String.class.getClassLoader())));
        this.createdAt = ((String) in.readValue((String.class.getClassLoader())));
        this.updatedAt = ((String) in.readValue((String.class.getClassLoader())));
        this.productparameters = ((Productparameters) in.readValue((Productparameters.class.getClassLoader())));
    }

    public Parameter() {
    }

    public List<String> getOptionValue() {
        return optionValue;
    }

    public void setOptionValue(List<String> optionValue) {
        this.optionValue = optionValue;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public String getUpdatedAt() {
        return updatedAt;
    }

    public void setUpdatedAt(String updatedAt) {
        this.updatedAt = updatedAt;
    }

    public Productparameters getProductparameters() {
        return productparameters;
    }

    public void setProductparameters(Productparameters productparameters) {
        this.productparameters = productparameters;
    }

    public void writeToParcel(Parcel dest, int flags) {
        dest.writeList(optionValue);
        dest.writeValue(id);
        dest.writeValue(name);
        dest.writeValue(type);
        dest.writeValue(remark);
        dest.writeValue(createdAt);
        dest.writeValue(updatedAt);
        dest.writeValue(productparameters);
    }

    public int describeContents() {
        return 0;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Parameter parameter = (Parameter) o;

        if (id != parameter.id) return false;
        return name.equals(parameter.name);
    }

    @Override
    public int hashCode() {
        int result = id;
        result = 31 * result + name.hashCode();
        return result;
    }

    @Override
    public int compareTo(@NonNull Parameter parameter) {
        return getId() - parameter.getId();
    }
}
